namespace TerritoryGame.Domain.ValueObjects;

/// <summary>
/// 玩家昵称值对象
/// </summary>
public record PlayerNickname
{
    public string Value { get; }
    
    public PlayerNickname(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("玩家昵称不能为空", nameof(value));
            
        if (value.Length < 2 || value.Length > 20)
            throw new ArgumentException("玩家昵称长度必须在2-20个字符之间", nameof(value));
            
        Value = value.Trim();
    }
    
    public static implicit operator string(PlayerNickname nickname) => nickname.Value;
    
    public override string ToString() => Value;
}
